from common.base import Base, By
from common.functions import open_browser
import time

class LoginPage(Base):
    login_url = 'http://139.129.26.163/user.php'  # 定义ECShop登录的的网址

    def input_username(self, username):
        time.sleep(2)
        self.send_keys((By.NAME, 'username'), username)

    def input_password(self, password):
        time.sleep(2)
        self.send_keys((By.NAME, 'password'), password)

    def remember(self):
        time.sleep(2)
        self.click(('id', 'remember'))

    def btn_login(self):
        time.sleep(2)
        self.click(('class name', 'us_Submit'))


if __name__ == '__main__':
    driver = open_browser()
    login = LoginPage(driver)
    login.get('http://139.129.26.163/user.php')
    login.input_username('ifmt2')
    login.input_password('a123456')
    login.remember()
    login.btn_login()
    login.quit(2)
